﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TSLB
    {

        public TSLB()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VLAGPL();
            DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "".PadRight(12);
                LB = "".PadRight(2); ;

            }
            else
            {
                LB = dwMaster["LPLB"].ToString(); 
                KEY = dwMaster["LPLO"].ToString() + dwMaster["LPLB"].ToString() ;
            }
        }
        public override void LOADBYAUF()
        {
            if (ORDERNUM.Length <4)
            {
                vwMaster.View.MoveCurrentTo(-1);
            }
            Locate("KLB", ORDERNUM.Substring(0,4));
        }
        public override void OnLPLOChg(string value)
        {
            if (value.Length < 2)
                return;

            dwData = TBMain.NewRow();
            dwData["LPMANDANT"] = app.Mandant;
            dwData["LPLO"] = "AND LPLO='" + value + "'";
            dwData["LPLB"] = "AND LPLB LIKE '%'";
            dwData["LPPLATZ"] = "AND LPPLATZ='        '";
            SResult = ((VLAGPL)MV).QueryLAGPL(dwData, -1);
            MergeData(SResult, false);
        } 
    }
}
